package com.hyh.fireworks.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hyh.fireworks.common.result.CommonPage;
import com.hyh.fireworks.entity.Posts;
import com.hyh.fireworks.mapper.PostsMapper;
import com.hyh.fireworks.service.IPostsService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 文章表 服务实现类
 * </p>
 *
 * @author summerday
 * @since 2020-11-07
 */
@Service
public class PostsServiceImpl extends ServiceImpl<PostsMapper, Posts> implements IPostsService {


    @Override
    public CommonPage<Posts> pageList(Long current, Long pageSize) {

        QueryWrapper<Posts> wrapper = new QueryWrapper<>();
        wrapper.orderByDesc("is_top")
                .orderByDesc("top_priority")
                .orderByDesc("published_time")
                .eq("status", 1);

        Page<Posts> postsPage = this.baseMapper.selectPage(new Page<>(current, pageSize), wrapper);
        return CommonPage.restPage(postsPage);

    }


}
